Notebook for generating class materials, checking links, and pushing materials into GitHub
In [1]:
# Load needed modules
from bs4 import BeautifulSoup
import requests
import sys
import warnings
warnings.filterwarnings("ignore")
In [2]:
# Set variables
checkFiles = [
"OILS515_syllabus.html",
"goalsAndObjectives/goalsAndObjectives.html"
]
In [3]:
%%bash
/usr/local/bin/pandoc --standalone --toc --latex-engine=pdflatex -V geometry:margin=1in -V fontsize:11pt -o OILS515_syllabus.pdf OILS515_syllabus.md
/usr/local/bin/pandoc --toc -s --standalone --css=page.css -o OILS515_syllabus.html OILS515_syllabus.md
/usr/local/bin/pandoc --toc -s --standalone --css=page.css -o index.html OILS515_syllabus.md
/usr/local/bin/pandoc -s -o OILS515_syllabus.epub OILS515_syllabus.md
In [ ]:
%%bash
cd goalsAndObjectives
/usr/local/bin/pandoc --toc -c page.css --standalone -o goalsAndObjectives.html goalsAndObjectives.md
/usr/local/bin/pandoc --standalone --toc --latex-engine=pdflatex -V geometry:margin=1in -V fontsize:11pt -o goalsAndObjectives.pdf goalsAndObjectives.md
In [ ]:
goodLinks = []
badLinks = []
for file in checkFiles:
print("\nProcessing: "+file)
with open(file) as activeFile:
soup = BeautifulSoup(activeFile, "lxml")
for link in soup.find_all('a'):
myLink = link.get('href')
if myLink[0] == "#":
print('0', end='')
else:
r = requests.get(myLink, verify=False)
# print("\t" + str(r.status_code))
if r.status_code == requests.codes.ok:
print('+', end='')
goodLinks.append([file,myLink,r.status_code])
else:
print('-', end='')
badLinks.append([file,myLink,r.status_code])
print("\n")
print("\n\n--- Good Links ---")
for link in goodLinks:
print(link)
print("\n\n--- Bad Links ---")
for link in badLinks:
print(link)
In [ ]:
%%bash
# define commit message
MESSAGE="Updated goals and objectives with correct term"
git pull
git add -A
git commit -m "$MESSAGE"
git push
In [ ]: